"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[172],{79123:function(e,t,n){n.d(t,{I:function(){return d}});var s=n(85893),l=n(67294),a=n(55299),r=n(52677),o=n(84283),c=n(19954);let i=e=>{let{text:t,type:n}=e;return(0,s.jsx)(a.D,{components:{code(e){let{node:t,inline:n,className:l,children:a,...c}=e,i=/language-(\w+)/.exec(l||"");return!n&&i?(0,s.jsx)(r.Z,{...c,style:o.Yn,language:i[1],PreTag:"div",children:String(a).replace(/\n$/,"")}):(0,s.jsx)("code",{...c,className:l,children:a})}},children:t})};function d(e){let{title:t,text:n,type:a="Documentation",extract:r,docLink:o}=e,d=(0,l.useRef)(null);if((0,l.useEffect)(()=>{if(d.current){let e=d.current;e.scrollIntoView({behavior:"smooth",block:"center"})}},[n,r]),!t)return(0,s.jsx)("div",{className:""});let u=r?n.indexOf(r):-1,p=r?u+r.length:-1;return(0,s.jsxs)("div",{className:"border-2 border-gray-900 shadow-lg rounded-xl bg-gray-100 p-2 animate-pop-in overflow-y-auto max-h-[498px] document-container",children:[(0,s.jsx)("div",{className:"".concat(c.DOC_TYPE_COLORS[a]," text-black p-4 rounded-t-xl w-full sticky top-0 z-10 shadow-md"),children:(0,s.jsx)("a",{href:o||"#",target:"_blank",rel:"noopener noreferrer",children:t||"Placeholder Title"})}),(0,s.jsxs)("div",{className:"p-4 my-markdown-styles text-sm font-mono",children:[-1!==u&&(0,s.jsx)(i,{text:n.slice(0,u),type:a}),r&&(0,s.jsx)("div",{ref:d,className:"".concat(c.DOC_TYPE_COLORS[a]," rounded-lg p-3 shadow-lg extract text-sm"),children:(0,s.jsx)(i,{text:n.slice(u,p),type:a})}),-1!==u?(0,s.jsx)("div",{className:"pt-3",children:(0,s.jsx)(i,{text:n.slice(p),type:a})}):(0,s.jsx)(i,{text:n,type:a})]})]})}},19954:function(e,t,n){n.r(t),n.d(t,{DOC_TYPE_COLORS:function(){return x},DOC_TYPE_COLOR_HOVER:function(){return f},apiHost:function(){return h},default:function(){return g},getApiHost:function(){return m}});var s=n(85893),l=n(67294),a=n(5459),r=n.n(a),o=n(52677),c=n(84283),i=n(92105),d=n.n(i);function u(e){let{onUserMessageSubmit:t,isFetching:n}=e,[a,i]=(0,l.useState)([]),u=(0,l.useRef)(null),p=e=>{let t=[],n=0;return e.replace(/```(.*?)\n([\s\S]*?)```/g,(s,l,a,r)=>(r>n&&t.push({type:"text",content:e.slice(n,r)}),t.push({type:"code",language:l.trim(),content:a.trim()}),n=r+s.length,s)),n<e.length&&t.push({type:"text",content:e.slice(n)}),t};return(0,l.useEffect)(()=>{if(t.length&&(0===a.length||t[t.length-1].content!==a[a.length-1].content)){let e=t[t.length-1];i(t=>[...t,e])}},[t]),(0,l.useEffect)(()=>{if(u.current){let e=a[a.length-1];if("system"===e.type){let t=25*e.content.length;setTimeout(()=>{var e;null===(e=u.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},t)}else u.current.scrollIntoView({behavior:"smooth"})}},[a]),(0,s.jsxs)("div",{className:"bg-gray-100 p-4 overflow-y-auto h-[350px]",children:[a.map((e,t)=>(0,s.jsx)("div",{ref:t===a.length-1?u:null,className:"mb-4 ".concat("user"===e.type?"text-right":""),children:(0,s.jsx)("span",{className:"inline-block p-3 rounded-xl animate-press-in shadow-md font-mono text-sm ".concat("user"===e.type?"bg-yellow-200":"bg-white"),children:"system"===e.type?p(e.content).map((e,t)=>"text"===e.type?(0,s.jsx)(r(),{onInit:t=>{t.typeString(e.content||"N/A").start()},options:{delay:15}},t):"code"===e.type?(0,s.jsx)(o.Z,{language:e.language,style:c.Yn,className:"rounded p-2",children:e.content},t):null):e.content})},t)),n&&(0,s.jsx)("div",{className:"flex items-center pl-4 mb-4",children:(0,s.jsx)(d(),{color:"#292929",loading:!0,size:10,speedMultiplier:.75})})]})}var p=n(79123);let m=()=>"",h=m(),x={Documentation:"bg-green-300",Blog:"bg-yellow-200"},f={Documentation:"hover:bg-green-400",Blog:"hover:bg-yellow-300"};function g(){let e;let[t,n]=(0,l.useState)([]),[a,r]=(0,l.useState)(""),[o,c]=(0,l.useState)(""),[i,d]=(0,l.useState)(""),[m,g]=(0,l.useState)("#"),[y,j]=(0,l.useState)([]),[b,v]=(0,l.useState)("Offline"),[w,N]=(0,l.useState)(null),[_,S]=(0,l.useState)([]),[O,C]=(0,l.useState)(!1),T=async()=>{try{let e=await fetch(h+"/api/health");200===e.status?v("Online"):v("Offline")}catch(e){v("Offline")}};(0,l.useEffect)(()=>{T()},[]);let k=async(e,t)=>{null==e||e.preventDefault();let s=t||a;if(s.trim()){S(e=>[...e,{type:"user",content:s}]),n([]),r(""),C(!0);try{T();let e=await fetch(h+"/api/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:s})}),t=await e.json();T(),j([]),j(t.documents),n([]),t.system&&S(e=>[...e,{type:"system",content:t.system}])}catch(e){T(),console.error("Failed to fetch from API:",e)}finally{C(!1)}}};(0,l.useEffect)(()=>{y&&y.length>0&&N(y[0])},[y]),(0,l.useEffect)(()=>{let e=async()=>{if(w&&w.doc_uuid)try{let e=await fetch(h+"/api/get_document",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({document_id:w.doc_uuid})}),t=await e.json();c(t.document.properties.doc_name),d(t.document.properties.text),g(t.document.properties.doc_link)}catch(e){console.error("Failed to fetch document:",e)}};e()},[w]);let E=async e=>{try{let t=await fetch(h+"/api/suggestions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e})}),s=await t.json();n(s.suggestions)}catch(e){console.error("Failed to fetch suggestions:",e)}},D=(e=null,function(){for(var t=arguments.length,n=Array(t),s=0;s<t;s++)n[s]=arguments[s];null!==e&&clearTimeout(e),e=window.setTimeout(()=>{null!==e&&clearTimeout(e),E(...n)},25)}),P=async e=>{r(e),k(void 0,e)},R=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),I=(e,t)=>{let n=R(t),l=e.split(RegExp("(".concat(n,")"),"gi"));return(0,s.jsx)("span",{children:l.map((e,n)=>(0,s.jsx)("span",{className:e.toLowerCase()===t.toLowerCase()?"font-bold text-sm":"",children:e},n))})};return(0,s.jsx)("main",{className:"flex min-h-screen flex-col items-center justify-between p-10 text-gray-900",children:(0,s.jsxs)("div",{className:"flex flex-col w-full items-start",children:[(0,s.jsxs)("div",{className:"mb-2",children:[(0,s.jsxs)("div",{className:"flex text-lg",children:[(0,s.jsx)("span",{className:"bg-opacity-0 rounded px-2 py-1 hover-container animate-pop-in",children:"The"}),(0,s.jsx)("span",{className:"bg-opacity-0 rounded font-bold px-2 py-1 hover-container animate-pop-in-late",children:"Golden"}),(0,s.jsx)("span",{className:"bg-yellow-200 rounded px-2 py-1 hover-container animate-pop-more-late",children:"RAGtriever \uD83D\uDC15"})]}),(0,s.jsxs)("div",{className:"flex items-center",children:[" ",(0,s.jsx)("h1",{className:"text-8xl font-bold mt-2",children:"Verba"}),(0,s.jsxs)("p",{className:"text-sm mt-16 text-gray-400 ml-4",children:[" ","Retrieval Augmented Generation system powered by Weaviate ❤️"]})]})]}),(0,s.jsx)("div",{className:"p-1 flex overflow-x-auto justify-center w-full mb-2",children:y.map((e,t)=>(0,s.jsx)("button",{onClick:()=>N(e),children:(0,s.jsxs)("div",{className:"".concat(x[e.doc_type]," rounded-lg text-xs hover-container shadow-lg border-2 hover:border-white border-black mx-1 h-32 w-48 p-3 ").concat(f[e.doc_type]," animate-pop-in"),children:[(0,s.jsx)("div",{className:"flex items-center",children:(0,s.jsx)("span",{className:"font-bold",children:e.doc_name})}),(0,s.jsxs)("div",{className:"flex justify-between space-x-1 mt-3",children:[(0,s.jsx)("div",{className:"text-xs bg-white bg-opacity-50 p-2 rounded-lg",children:e.doc_type}),(0,s.jsxs)("div",{className:"text-xs bg-white bg-opacity-50 p-2 rounded-lg",children:[" ","Score ",Math.round(1e4*e._additional.score)]})]})]})},e.doc_name+t))}),(0,s.jsxs)("div",{className:"flex w-full space-x-4",children:[(0,s.jsxs)("div",{className:"w-1/2 p-2 border-2 shadow-lg h-2/3 border-gray-900 rounded-xl animate-pop-in",children:[(0,s.jsxs)("div",{className:"rounded-t-xl bg-yellow-200 p-4 flex justify-between items-center",children:["Verba Chat",(0,s.jsx)("div",{className:"text-xs text-white font-mono flex justify-center",children:(0,s.jsxs)("span",{className:"rounded-indicator text-white p-2 ".concat("Online"===b?"bg-green-500":"bg-red-500"),children:["Demo ",b]})})]}),(0,s.jsx)(u,{onUserMessageSubmit:_,isFetching:O}),(0,s.jsx)("form",{className:"rounded-b-xl bg-gray-800 p-4 relative",onSubmit:k,children:(0,s.jsx)("input",{type:"text",value:a,onChange:e=>{r(e.target.value),D(e.target.value)},placeholder:"What is a vector database?",className:"w-full p-2 rounded-md bg-white text-gray-900 placeholder-gray-400"})}),(0,s.jsx)("div",{className:"absolute mt-2 p-2 z-10 w-1/2 left-5 text-center justify-center",children:t.map((e,t)=>(0,s.jsx)("div",{className:"p-2 hover:bg-green-200 bg-gray-200 cursor-pointer shadow-md rounded-md text-xs animate-press-in mt-2 hover-container",onClick:()=>P(e),children:I(e,a)},t))})]}),(0,s.jsx)("div",{className:"w-1/2 space-y-4",children:(0,s.jsx)(p.I,{title:o,text:i,extract:null==w?void 0:w.text,docLink:m,type:null==w?void 0:w.doc_type})})]})]})})}}}]);